package com.lib.controller.user;

import com.lib.pojo.VO.CategoryVO;
import com.lib.pojo.VO.RcommendVO;
import com.lib.pojo.entity.Result;
import com.lib.service.RecommendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("UserRecommendController")
@RequestMapping("/user/recommends")
@Slf4j
@Tag(name = "套餐图书接口")
public class RecommendController {
    @Autowired
    private RecommendService recommendService;

    /**
     * 根据套餐ID查询图书
     *
     * @param recommendId 套餐ID
     * @return 图书列表
     */
    @GetMapping("/recommendId")
    @Operation(summary = "根据套餐ID查询图书")
    public Result<List<RcommendVO>> getRecommend(Integer recommendId) {
        log.info("根据套餐ID查询图书: {}", recommendId);
        List<RcommendVO> rcommendVOS = recommendService.getRecommendById(recommendId);
        return Result.success(rcommendVOS);
    }

    /**
     * 根据套餐ID查询套餐信息
     *
     * @param recommendId 套餐ID
     * @return 套餐信息
     */
    @GetMapping("/info/{recommendId}")
    @Operation(summary = "根据套餐ID查询套餐信息")
    public Result<List<RcommendVO>> getRecommendInfo(@PathVariable Integer recommendId) {
        log.info("根据套餐ID查询套餐信息: {}", recommendId);
        List<RcommendVO> recommendVOS = recommendService.getRecommendInfoById(recommendId);
        return Result.success(recommendVOS);
    }
}
